Welcome back to part two and we have still imparted the cap data frame.
So let's have a look.
So these are the market capitalizations for our constituents over time and then evaluated index each
constituent has a way to corresponding to its proportional market capitalization.
So therefore we have to calculate for each single timestamp.
The total market capitalization for the constituents or to say the sum so we can do this with the sum
method.
So nothing new here.
So this is uh on each timestamp the sum of market caps.
Now we can actually calculate the weights of the constituents for each single timestamp and we can do
this by dividing our M cap data frame by the total sum here.
So actually for each single timestamp we actually calculate the proportion for each of the constituents.
And uh we pass the index to the access parameter so here we have for each and every timestamp.
The rates.
So the proportional weights as per our market capitalization.
And we can also save uh the weights data frame and the variable weights evaluated index.
And let's again have a look at the last five rows here and 2000 and 18.
And also here it makes sense to visualize the evolution of weights over time and we can do this here
with the plot method on our weights evaluated index data frame so these is the evolution of weights
and we can see here that uh the weight of the Microsoft the stock in our value weighted index is quite
stable over time.
So from 27 percent to about 35 percent and we have a significantly increasing weight of the Amazon stock
starting from uh below 20 percent total.
Also 34 thought 35 percent.
So these are the weights of the constituents and our value weighted index.
And uh yeah we can see that our value weighted index is kind of concentrated in two positions.
So in the Amazon stock and in the Microsoft stock.
So we are pretty far away from having a very diversified index portfolio.
And now when the next step let's calculate the daily returns of our stock prices and we can do this
with the percentage change method.
So nothing new here.
So these are the daily returns.
And in addition to the daily returns we have also the daily rates.
So that's again have a look here.
And that's actually one pitfall that we have to keep in mind.
So we can see here in the returns data frame the very first return we have on the second of January
2014.
So the immediately preceding price we had on the thirty first of December 2000 and uh 13 then the first
of January was a bank holiday.
And then on the 2nd of January we have um uh these daily returns here and these daily returns are based
on the last price on the thirty first of December.
And therefore if you want to calculate the weighted average return on the 2nd of January we have to
do this with the rates of the thirty first of December so the next step we want to calculate for each
single time stamp the weighted average return of our value weighted index by multiplying here the returns
of our six constituents by the way.
And we have to keep in mind that we have to shift our weights by one day.
So we have to multiply the weights at the end of the thirty first of December with the return on the
second.
And uh we can do this here with the shift asset so let's do this here.
So here we have shifted forward all rates by one day.
So now we have the weights that we have to use the calculated the weighted average return on the 2nd
of January here at the 2nd of January.
And finally we should also drop here the very first row
and calculating the weighted average returns for each single timestamp is actually now what we do.
So we take our returns data frame and multiply it here with our shifted weights data frame.
So let's have a look.
So these are the daily returns of our six constituents made it by their respective rates.
And finally we have to sum it up to get the weighted average return.
So let's sort this
so these are now the daily returns of our value weighted index.
And um now we are only one step away from our value weighted index.
So first of all we create the column in our norm data frame value weighted index and we assign 100 to
each and every timestamp so here we are on the right hand side of our value weighted index.
And same as with the equal weighted index.
Now we can calculate for each and every a timestamp the cumulative investment might.
And we can do this by adding one to each and every uh daily return.
Then we are calculating the cumulative product.
And this actually gives us uh then the cumulative investment multiple for each timestamp.
And finally we multiply each uh multiple with 100 because uh we are starting here with a base value
on normalized value of 100.
So let's do this here.
And here we have actually a beginning from the second of January our values for our value weighted index.
So at the very first day it's 100 then you add the second day it's ninety nine point three two.
And so on and therefore now we can over variety beginning from the second element.
We can over variety of the values in our column value weighted index and exactly with the values that
we calculated here.
So let's do this and let's have a final look here so here we have our fine uh normalized data frame
with the normalized prices of our six constituents.
And in addition we FBA the three indexes the price weighted index so the equal weighted index and the
value weighted index.
And we can also visualize our new evaluated and next year with the six constituents.
And here we can see in dark blue.
So this this year our evaluated index so we are finished now with this video and in the next video we
will compare our three indexes.
So hope to see you also there by.